<?php
class View {
	var $filename;
	var $controller;

	public function __construct($filename) {
		$this->filename = $_SERVER['DOCUMENT_ROOT'].$filename;
	}
	
	public function assignController($controller) {
		$this->controller = $controller;
	}
	
	public function display($vars) {
		if (is_array($vars)) {
			foreach($vars as $key => $value) {
				$$key = $value;
			}
		}
		
		if (is_string($this->controller)) {
			$cotrollerUri = Controller::getUri();
			$cotrollerName = $this->controller;
			$cotrollerId = "";
		} else if ((is_object($this->controller)) && (is_subclass_of($this->controller, "Controller"))) {
			$cotrollerUri = $this->controller->getUri();
			$cotrollerName = $this->controller->getName();
			$cotrollerId = $this->controller->getId();
		}
		
		$fh = fopen($this->filename, "r");
		$content = fread($fh, filesize($this->filename));
		fclose($fh);
		
		eval("echo ''; ?>".$content."<? echo '';");
	}
}
?>